package com.hk.aefz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hk.aefz.po.Account;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 账户表 Mapper 接口
 * </p>
 *
 * @author 阿尔法哲
 * @since 2020-07-21
 */
public interface AccountMapper extends BaseMapper<Account> {

    /**
     * 账户关联中间表
     * @param aid
     * @param rid
     * @param gmtCreate
     * @param gmtModified
     */
    @Insert("insert into account_role values (null,#{rid},#{aid},#{gmtCreate},#{gmtModified})")
    void accountRoleSave(@Param("aid") int aid,@Param("rid") int rid,@Param("gmtCreate") String gmtCreate,@Param("gmtModified") String gmtModified);

    /**
     * 根据账户id查询角色
     * @param aid
     * @return
     */
    @Select("select r.rname from role r join account_role ar on r.rid = ar.rid and ar.aid = #{aid};")
    Set<String> selectByAid(@Param("aid") Integer aid);

}
